package com.qin.entity.subcomponents;

import com.qin.entity.ExecuteBean;
import com.qin.entity.ExecuteLog;
import com.qin.service.ExecuteService;
import com.qin.service.impl.ExecuteServiceImpl;

import java.util.HashMap;
import java.util.Map;

/*
 * 【子组件】生成临时变量
 */
public class TempParaSubComponent {

    //变量名
    private String temp_paraname;
    //变量值
    private String temp_paravalue;

    private ExecuteService executeService = new ExecuteServiceImpl();

    public TempParaSubComponent(String temp_paraname, String temp_paravalue) {
        this.temp_paraname = temp_paraname;
        this.temp_paravalue = temp_paravalue;
    }

    public void execute(ExecuteBean executeBean){

        //设置ExecuteLog对象的各属性
        ExecuteLog executeLog = new ExecuteLog(executeBean.getExecute_id(), executeBean.getFunction_id(),
                executeBean.getTestcase_id(), executeBean.getComponent_id(), executeBean.getSubcomponent_id(), "");

        Map<String, String> retMap = new HashMap();
        retMap.put(temp_paraname, temp_paravalue);

        //插入日志
        executeService.insertExecuteLog(executeLog, ">>>>>生成临时变量：变量名=" + temp_paraname + "，变量值=" + temp_paravalue);

        //把map的值添加到executeBean中
        executeBean.getParaMap().putAll(retMap);
    }

}
